#!/usr/bin/perl

use StaticToolTest;
use TestPackage;

@tests = TestPackage::getTests();
TestPackage::printTests( @tests );

@tools = ( 
"gcc",
"clang",
"splint",
"cppcheck"
);

foreach $tool (@tools) { run ( $tool . "Test" ); }

createReport();

sub run {
	my $toolTest = shift;
	printf("$toolTest\n");
	$toolTest = "StaticToolTest::" . $toolTest;
	foreach $test (@tests) { 
		printf("\t$test\n");
		&$toolTest ( $test ); 
	}
}

sub createReport {
	my $master = "reports/master";

	unless ( -e "reports" ) {
		mkdir "reports";
	}
	if ( -e $master ) {
		system ("rm $master");
	}
	foreach $test (@tests) { 
		my $report = "reports/$test";
		if ( -e $report ) {
			system ("rm $report");
		}
		system ("echo /*------------------------$test----------------------*/ >> $report");
		system ("echo >> $report");
		system ("cat -n tests/$test.c >> $report");
		foreach $tool (@tools) {
			my $log = StaticToolTest::createLogName($test, $tool);
			system ("echo  >> $report");
			system ("echo /******--$tool--*******/ >> $report");
			system ("echo  >> $report");
			system ("cat $log >> $report");
		}
		system ("echo  >> $master");
		system ("cat $report >> $master");
	}
}
1;

